os——可移植的访问操作系统的特定功能

原文地址:https://pymotw.com/3/os/index.html

目的:可移植的访问操作系统的特定功能。

os模块为平台特定模块(比如posixntmac)提供了一个包装器。所有平台的函数API应该相同,所以使用os模块提供了一些可移植的措施。但是,不是所有函数在每个平台都有效。本文描述的很多进程管理函数在Windows上无效。

os模块的Python文档中,它的子标题是“各种操作系统接口”。该模块主要包括创建和管理运行的进程或文件系统的内容(文件和目录)的函数,以及一些其它功能。

1、检查文件系统的内容

使用listdir()返回文件系统中一个目录的内容列表。

# os_listdir.py

import os
import sys

print(os.listdir(sys.argv[1]))

返回值是给定目录中所有命名成员的列表。文件,子目录和符号链接之间没有区别。

$ python3 os_listdir.py .

['index.rst', 'os_access.py', 'os_cwd_example.py',
'os_directories.py', 'os_environ_example.py',
'os_exec_example.py', 'os_fork_example.py',
'os_kill_example.py', 'os_listdir.py', 'os_listdir.py~',
'os_process_id_example.py', 'os_process_user_example.py',
'os_rename_replace.py', 'os_rename_replace.py~',
'os_scandir.py', 'os_scandir.py~', 'os_spawn_example.py',
'os_stat.py', 'os_stat_chmod.py', 'os_stat_chmod_example.txt',
'os_strerror.py', 'os_strerror.py~', 'os_symlinks.py',
'os_system_background.py', 'os_system_example.py',
'os_system_shell.py', 'os_wait_example.py',
'os_waitpid_example.py', 'os_walk.py']

walk()函数递归遍历一个目录,并为每个子目录生成一个元组,其中包括目录路径,该路径的所有直接子目录,以及一个该目录下所有文件名的列表。

# os_walk.py

import os
import sys

# If we are not given a path to list, use /tmp
if len(sys) == 1:
    root = '/tmp'
else:
    root = sys.argv[1]
    
for dir_name, sub_dirs, files in os.walk(root):
    print(dir_name)
    # Make the subdirectory names stand out with /
    sub_dirs = [n + '/' for n in sub_dirs]
    # Mix the directory contents together
    contents = sub_dirs + files
    contents.sort()
    # Show the contents
    for c in contents:
        print('  {}'.format(c))
    print()

这个例子显示一个递归的目录列表。

$ python3 os_walk.py ../zipimport

../zipimport
  __init__.py
  example_package/
  index.rst
  zipimport_example.zip
  zipimport_find_module.py
  zipimport_get_code.py
  zipimport_get_data.py
  zipimport_get_data_nozip.py
  zipimport_get_data_zip.py
  zipimport_get_source.py
  zipimport_is_package.py
  zipimport_load_module.py
  zipimport_make_example.py

../zipimport/example_package
  README.txt
  __init__.py

如果需要文件名之外的更多信息,scandir()listdir()更高效,因为扫描目录时只需要执行一次系统调用就能收集更多信息。

# os_scandir.py

import os
import sys

for entry in os.scandir(sys.argv[1]):
    if entry.is_dir():
        typ = 'dir'
    elif entry.is_file():
        typ = 'file'
    elif entry.is_symlink():
        typ = 'link'
    else:
        typ = 'unknow'
    print('{name} {typ}'.format(
        name=entry.name,
        typ=typ,
    ))

scandir()返回为目录中的项目返回一个DirEntry实例的序列。该对象有一些访问文件元数据的属性和方法。

$ python3 os_scandir.py .

index.rst file
os_access.py file
os_cwd_example.py file
os_directories.py file
os_environ_example.py file
os_exec_example.py file
os_fork_example.py file
os_kill_example.py file
os_listdir.py file
os_listdir.py~ file
os_process_id_example.py file
os_process_user_example.py file
os_rename_replace.py file
os_rename_replace.py~ file
os_scandir.py file
os_scandir.py~ file
os_spawn_example.py file
os_stat.py file
os_stat_chmod.py file
os_stat_chmod_example.txt file
os_strerror.py file
os_strerror.py~ file
os_symlinks.py file
os_system_background.py file
os_system_example.py file
os_system_shell.py file
os_wait_example.py file
os_waitpid_example.py file
os_walk.py file

2、管理文件系统的权限

使用stat()lstat()(用于检查可能是符号链接的状态)可以访问一个文件的详细信息。

# os_stat.py

import os
import sys
import time

if len(sys.argv) == 1:
    filename = __file__
else:
    filename = sys.argv[1]
    
stat_info = os.stat(filename)

print('os.stat({}):'.format(filename))
print('  Size:', stat_info.st_size)
print('  Permissions:', oct(stat_info.st_mode))
print('  Owner:', stat_info.st_uid)
print('  Device:', stat_info.st_dev)
print('  Created      :', time.ctime(stat_info.st_ctime))
print('  Last modified:', time.ctime(stat_info.st_mtime))
print('  Last accessed:', time.ctime(stat_info.st_atime))

输出结果取决于示例代码是如何运行的。尝试在命令行中传递不同的文件名到os_stat.py中。

$ python3 os_stat.py

os.stat(os_stat.py):
  Size: 593
  Permissions: 0o100644
  Owner: 527
  Device: 16777218
  Created      : Sat Dec 17 12:09:51 2016
  Last modified: Sat Dec 17 12:09:51 2016
  Last accessed: Sat Dec 31 12:33:19 2016

$ python3 os_stat.py index.rst

os.stat(index.rst):
  Size: 26878
  Permissions: 0o100644
  Owner: 527
  Device: 16777218
  Created      : Sat Dec 31 12:33:10 2016
  Last modified: Sat Dec 31 12:33:10 2016
  Last accessed: Sat Dec 31 12:33:19 2016

在类Unix系统上,可以传递一个整数作为模式给chmod(),来修改文件权限。模式值可以使用在stat模块中定义的常量构建。下面这个例子切换用户的执行权限位:

# os_stat_chmod.py

import os
import stat

filename = 'os_stat_chmod_example.txt'
if os.path.exists(filename):
    os.unlink(filename)
with open(filename, 'wt') as f:
    f.write('content')
    
# Determine what permissions are already set using stat
existing_permissions = stat.S_IMODE(os.stat(filename).st_mode)

if not os.access(filename, os.X_OK):
    print('Adding excute permission')
    new_permissions = existing_permissions | stat.S_IXUSR
else:
    print('Removing execute permission')
    new_permissions = existing_permissions ^ stat.S_IXUSR
    
os.chmod(filename, new_permissions)

这个脚本假设它具有在运行时修改文件模式所需的权限。

$ python3 os_stat_chmod.py

Adding execute permission

access()函数用于测试进程对文件的访问权限。

# os_access.py

print('Testing:', __file__)
print('Exists:', os.access(__file__, os.F_OK))
print('Readable:', os.access(__file__, os.R_OK))
print('Writable:', os.access(__file__, os.W_OK))
print('Executable:', os.access(__file__, os.X_OK))

结果取决于如何运行实例代码,但输出类似这样:

$ python3 os_access.py

Testing: os_access.py
Exists: True
Readable: True
Writable: True
Executable: False

access()的库文档包括两个特殊警告。第一个,在一个文件上调用open()之前,调用access()测试文件是否可以被打开没有意义。在这两次调用之间有很短的,但确实存在的时间间隔,期间文件的权限有可能被改变。另一个警告主要适用于扩展自POSIX权限语义的联网文件系统。某些文件系统类型可能会响应进程有权限访问文件的POSIX调用,然后由于某些原因没有通过POSIX调用测试,尝试使用open()时会出错。总而言之,最好使用需要的模式调用open(),并捕获出错时抛出的IOError

3、创建和删除目录

有几个函数用于操作文件系统中的目录,包括创建,列出内容和删除它们。

# os_directories.py

dir_name = 'os_directories_example'

print('Creating', dir_name)
os.makedirs(dir_name)

file_name = os.path.join(dir_name, 'example.txt')
print('Creating', file_name)
with open(file_name, 'wt') as f:
    f.write('example file')

print('Cleaning up')
os.unlink(file_name)
os.rmdir(dir_name)

有两个函数集用于创建和删除目录。使用mkdir()创建一个新目录时,所有父目录必须已经存在。使用rmdir()删除一个目录时,只有叶子目录(路径的最后一部分)会真正的被删除。相反,makedirs()removedirs()会操作路径中的所有节点。makedirs()会创建路径中所有不存在的部分,removedirs()会删除所有父目录,知道它们为空。

$ python3 os_directories.py

Creating os_directories_example
Creating os_directories_example/example.txt
Cleaning up

4、使用符号链接

对于支持符号链接的平台和文件系统,有些函数用于符号链接。

# os_symlinks.py

import os

link_name = '/tmp/' + os.path.basename(__file__)

print('Creating link {} -> {}'.format(link_name, __file__))
os.symlink(__file__, link_name)

stat_info = os.lstat(link_name)
print('Permissions:', oct(stat_info.st_mode))

print('Points to:', os.readlink(link_name))

# Cleanup
os.unlink(link_name)

使用symlink()创建一个符号链接,readlink()读取链接,确定它指向的原始文件。lstat()函数类似stat(),但是它在符号链接上运行。

$ python3 os_symlinks.py

Creating link /tmp/os_symlinks.py -> os_symlinks.py
Permissions: 0o120755
Points to: os_symlinks.py

5、安全地替换已存在的文件

替换或重命名已存在文件不是幂等的,并且可能把应用程序暴露于竞争条件。对于这些操作,rename()replace()函数可以在兼容POSIX系统上使用原子操作来实现安全的算法。

# os_rename_replace.py

import glob
import os

with open('rename_start.txt', 'w') as f:
    f.write('starting as rename_start.txt')
    
print('Starting:', glob.glob('rename*.txt'))

os.rename('rename_start.txt', 'rename_finish.txt')

print('After rename:', glob.glob('rename*.txt'))

with open('rename_finish.txt', 'r') as f:
    print('Contents:', repr(f.read()))
    
with open('rename_new_contents.txt', 'w') as f:
    f.write(ending with contents of rename_new_contents.txt')
    
os.replace('rename_new_contents.txt', 'rename_finish.txt')

with open('rename_new_contents.txt', 'r') as f:
    print('After replace:', repr(f.read()))
    
for name in glob.glob('rename*.txt'):
    os.unlink(name)

大多数时候,rename()replace()函数可以跨文件系统工作。如果将文件移动到新文件系统,或者目标已经存在,则重命名文件可能会失败。

$ python3 os_rename_replace.py

Starting: ['rename_start.txt']
After rename: ['rename_finish.txt']
Contents: 'starting as rename_start.txt'
After replace: 'ending with contents of rename_new_contents.txt'

6、检测和修改进程所有者

os提供的下一组函数用于确定和修改进程所有者的ID。这最常被守护程序或特殊系统程序的作者用于修改权限级别,而不是以root身份运行。本节不会解释Unix安全性,进程所有者等的所有错综复杂的细节。有关详细信息请参考本节末尾的参考列表。

下面这个示例显示了一个进程的real和effective用户和组的信息,然后修改effective值。这类似于系统引导期间,守护程序以root身份启动时需要完成一些工作,用于降低权限级别,并以另一个用户运行。

注意:运行示例之前,修改TEST_GIDTEST_UID值为系统中定义的real用户。

# os_process_user_example.py

import os

TEST_GID = 502
TEST_UID = 502

def show_user_info():
    print('User (actual/effective)  :  {} / {}'.format(
        os.getuid(), os.geteuid()))
    print('Group (actual/effective)  :  {} / {}'.format(
        os.getgid(), os.getegid()))
    print('Actual Groups  :', os.getgroups())
    
print('BEFORE CHANGE:')
show_user_info()
print()

try:
    os.setgid(TEST_ID)
except OSError:
    print('ERROR: Could not change effective group. '
          'Rerun as root.')
else:
    print('CHANGE GROUP:')
    show_user_info()
    print()

try:
    os.seteuid(TEST_ID)
except OSError:
    print('ERROR: Could not change effective user. '
          'Rerun as root.')
else:
    print('CHANGE USER:')
    show_user_info()
    print()

当在OS X上运行的用户ID为502,组为502时,产生以下输出:

$ python3 os_process_user_example.py

BEFORE CHANGE:
User (actual/effective)  : 527 / 527
Group (actual/effective) : 501 / 501
Actual Groups   : [501, 701, 402, 702, 500, 12, 61, 80, 98, 398,
399, 33, 100, 204, 395]

ERROR: Could not change effective group. Rerun as root.
ERROR: Could not change effective user. Rerun as root.

值不会修改,因为它没有作为root运行,一个进程不能修改它的effective所有者的值。任何设置effective user id或group id为当前用户之外的其它值都会导致OSError。使用sudo运行同一个脚本,用root权限开始一个不同的场景。

$ sudo python3 os_process_user_example.py

BEFORE CHANGE:

User (actual/effective)  : 0 / 0
Group (actual/effective) : 0 / 0
Actual Groups : [0, 1, 2, 3, 4, 5, 8, 9, 12, 20, 29, 61, 80,
702, 33, 98, 100, 204, 395, 398, 399, 701]

CHANGE GROUP:
User (actual/effective)  : 0 / 0
Group (actual/effective) : 0 / 502
Actual Groups   : [0, 1, 2, 3, 4, 5, 8, 9, 12, 20, 29, 61, 80,
702, 33, 98, 100, 204, 395, 398, 399, 701]

CHANGE USER:
User (actual/effective)  : 0 / 502
Group (actual/effective) : 0 / 502
Actual Groups   : [0, 1, 2, 3, 4, 5, 8, 9, 12, 20, 29, 61, 80,
702, 33, 98, 100, 204, 395, 398, 399, 701]

这种情况下,因为用root启动,所以脚本会修改进程的effective user和group。一旦修改了effective UID,进程会被限制在该用户的权限下。因为非root用户不能修改它们的effective group,所以程序需要在修改用户之前修改组。

7、管理进程环境

操作系统通过os模块暴露给程序的另一个特征是环境。在环境中设置的变量作为字符串可见,可以通过os.environgetenv()读取。环境变量通常用于配置搜索路径,文件位置和调试标识等值。这个示例显示了如何检索一个环境变量,以及传递一个值给子进程。

# os_environ_example.py

import os

print('Initial value:', os.environ.get('TESTVAR', None))
print('Child process:')
os.system('echo $TESTVAR')

os.environ['TESTVAR'] = 'THIS VALUE WAS CHANGED'

print()
print('Changed value:', os.environ['TESTVAR'])
print('Child process:')
os.system('echo $TESTVAR')

del os.environ['TESTVAR']

print()
print('Remove value:', os.environ.get('TESTVAR', None))
print('Child process:')
os.system('echo $TESTVAR')

os.environ对象遵循标准的Python映射API,用于检索和设置值。对os.environ的修改会为子进程导出。

$ python3 -u os_environ_example.py

Initial value: None
Child process:


Changed value: THIS VALUE WAS CHANGED
Child process:
THIS VALUE WAS CHANGED

Removed value: None
Child process:

8、管理进程工作目录

带层级文件系统的操作系统有当前工作目录的概念——当用相对路径访问文件时,进程用作起始位置的目录。可以使用getcwd()查询当前工作目录,使用chdir()修改。

# os_cwd_example.py

import os

print('Starting:', os.getcwd())

print('Moving up one:', os.pardir)
os.chdir(os.pardir)

print('After move:', os.getcwd())

os.curdiros.pardir用于指向当前目录和父目录。

$ python3 os_cwd_example.py

Starting: .../pymotw-3/source/os
Moving up one: ..
After move: .../pymotw-3/source

9、运行外部命令

警告:
用于处理进程的很多函数的移植性是有限制的。要以平台独立的方式,以更一致的方法使用进程,请参考subprocess模块。

运行独立命令的最基本的,并且不与它交互的方式是使用system()。它接收单个字符串参数,它是被子进程在shell中执行的命令行。

# os_system_example.py

import os

# Simple command
os.system('pwd')

system()的返回值是shell执行程序的退出值,它被打包成一个16 bit的数字,其中高字节是退出状态,低字节是导致进程死亡的信号数或者0。

$ python3 -u os_system_example.py

.../pymotw-3/source/os

因为命令直接传递给shell处理,所以可以包括shell语法,比如通配符或者环境变量。

# os_system_shell.py

import os

# Command with shell expansion
os.system('echo $TMPDIR')

当shell执行命令行时,字符串中的环境变量TMPDIR会被展开。

$ python3 -u os_system_shell.py

/var/folders/5q/8gk0wq888xlggz008k8dr7180000hg/T/

除非命令明确地在后台执行,否则调用system()会阻塞,直到完成执行。默认情况下,子进程的标准输入,输出和错误与调用者拥有的适当流关联,但是可以使用shell语法重定向。

# os_system_background.py

import os
import time

print('Calling...')
os.system('date; (sleep 3; date) &')

print('Sleeping...')
time.sleep(5)

尽管这正好掉进了shell的诡计中,但是有更好的方式完成同样的任务。

$ python3 -u os_system_background.py

Calling...
Sat Dec 31 12:33:20 EST 2016
Sleeping...
Sat Dec 31 12:33:23 EST 2016

10、使用os.fork()创建进程

POSIX函数fork()exec()(在Mac OS X,Linux和其它Unix版本下可用)通过os模块暴露。已经有很多书籍介绍了可靠的使用这些函数,所以在图书馆或书店查阅更多细节,这里只是一个简介。

使用fork()创建一个新进程,作为当前进程的克隆:

# os_fork_example.py

import os

pid = os.fork()

if pid:
    print('Child process id:', pid)
else:
    print('I am the child')

每次运行示例时,输入取决于系统的状态,但它看起来是这样的:

$ python3 -u os_fork_example.py

Child process id: 29190
I am the child

fork之后会有两个进程执行同样的代码。通过检查fork()的返回值,告诉程序在哪个进程中。如果值为0,则当前是子进程。如果不为0,则程序在父进程中执行,返回值是子进程的进程ID。

# os_kill_example.py

import os
import signal
import time


def signal_usr1(signum, frame):
    "Callback invoked when a signal is received"
    pid = os.getpid()
    print('Received USR1 in process {}'.format(pid))


print('Forking...')
child_pid = os.fork()
if child_pid:
    print('PARENT: Pausing before sending signal...')
    time.sleep(1)
    print('PARENT: Signaling {}'.format(child_pid))
    os.kill(child_pid, signal.SIGUSR1)
else:
    print('CHILD: Setting up signal handler')
    signal.signal(signal.SIGUSR1, signal_usr1)
    print('CHILD: Pausing to wait for signal')
    time.sleep(5)

父进程可以使用kill()signal模块发送信号到子进程。首先定义一个接收到信号时触发的信号处理器。然后fork(),并在用kill()发送USR1信号之前,在父进程中暂停一小段时间。这个示例用暂停让子进程有时间设置信号处理器。实际程序中,不需要(或者不希望)调用sleep()。在子进程中设置信号处理器,并休眠一段时间,让父进程发送信号。

$ python3 -u os_kill_example.py

Forking...
PARENT: Pausing before sending signal...
CHILD: Setting up signal handler
CHILD: Pausing to wait for signal
PARENT: Signaling 29193
Received USR1 in process 29193

在子进程中处理独立行为的一种简单方法是检查fork()的返回值,然后分支。更复杂的行为可能需要比简单分支更多的独立代码。其它情况下,可能需要包装已经存在的程序。对于这两种情况,exec*()函数系列可以用于运行其它程序。

# os_exec_example.py

import os

child_pid = os.fork()
if child_pid:
    os.waitpid(child_pid, 0)
else:
    os.execlp('pwd', 'pwd', '-P')

当程序通过exec()运行时,该程序的代码会替换已存在进程中的代码。

$ python3 os_exec_example.py

.../pymotw-3/source/os

根据参数的可用形式,父进程的路径和环境是否应该拷贝到子进程中等,exec()有很多变体。对于所有变种,第一个参数是路径或文件名,剩余的参数控制程序如何执行。它们作为命令行参数传递,或者覆盖进程环境(参考os.environos.getenv)。完整细节请参考库文档。

11、等待子进程

很多计算密集型程序使用多进程来解决Python和全局解释器锁的线程限制。当启动多个进程执行独立的任务时,主机需要等待其中一个或多个进程完成,然后再启动新进程,以避免服务器超负荷。使用wait()和相关函数有几种不同的方式。

不管哪个子进程先退出不重要时,使用wait()。一旦任何子进程退出就会返回。

# os_wait_example.py

import os
import sys
import time

for i in range(2):
    print('PARENT {}: FORKING {}'.format(os.getpid(), i))
    worker_pid = os.fork()
    if not worker_pid:
        print('WORKER {}: Starting'.format(i))
        time.sleep(2 + i)
        print('WORKER {}: Finishing'.format(i))
        sys.exit(i)

for i in range(2):
    print('PARENT: Waiting for {}'.format(i))
    done = os.wait()
    print('PARENT: Child done:', done)

wait()的返回值是一个元组,其中包括进程ID和组合为16 bit值的退出状态。低字节是杀死进程的信号数字,高字节是进程退出时返回的状态码。

$ python3 -u os_wait_example.py

PARENT 29202: Forking 0
PARENT 29202: Forking 1
PARENT: Waiting for 0
WORKER 0: Starting
WORKER 1: Starting
WORKER 0: Finishing
PARENT: Child done: (29203, 0)
PARENT: Waiting for 1
WORKER 1: Finishing
PARENT: Child done: (29204, 256)

使用waitpid()等待指定进程。

# os_waitpid_example.py

import os
import sys
import time

workers = []
for i in range(2):
    print('PARENT {}: Forking {}'.format(os.getpid(), i))
    worker_pid = os.fork()
    if not worker_pid:
        print('WORKER {}: Starting'.format(i))
        time.sleep(2 + i)
        print('WORKER {}: Finishing'.format(i))
        sys.exit(i)
    workers.append(worker_pid)

for pid in workers:
    print('PARENT: Waiting for {}'.format(pid))
    done = os.waitpid(pid, 0)
    print('PARENT: Child done:', done)

传递目标进程的进程ID,waitpid()会阻塞直到该进程退出。

$ python3 -u os_waitpid_example.py

PARENT 29211: Forking 0
PARENT 29211: Forking 1
PARENT: Waiting for 29212
WORKER 0: Starting
WORKER 1: Starting
WORKER 0: Finishing
PARENT: Child done: (29212, 0)
PARENT: Waiting for 29213
WORKER 1: Finishing
PARENT: Child done: (29213, 256)

wait3()wait4()以类似的方式工作,但是会返回子进程更详细的信息,包括pid,退出状态和资源使用情况。

12、生成新进程

为了方便,spawn()函数族在一条语句中处理fork()exec()

# os_spawn_example.py

import os

os.spawnlp(os.P_WAIT, 'pwd', 'pwd', '-P')

第一个参数是模式,指定返回之前是否等待进程完成。这个示例中等待进程完成。使用P_NOWAIT让其它进程启动,然后在当前进程中继续。

$ python3 os_spawn_example.py

.../pymotw-3/source/os

13、操作系统错误码

由操作系统定义,并在errno模块中管理的错误码可以使用strerror()翻译为消息字符串。

# os_strerror.py

import errno
import os

for num in [errno.ENOENT, errno.EINTR, errno.EBUSY]:
    name = errno.errorcode[num]
    print('[{num:>2}] {name:<6}: {msg}'.format(
        name=name, num=num, msg=os.strerror(num)))

这个示例显示了与某些频繁出现的错误代码相关联的消息。

$ python3 os_strerror.py

[ 2] ENOENT: No such file or directory
[ 4] EINTR : Interrupted system call
[16] EBUSY : Resource busy

参考

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,015评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,262评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,727评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,986评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,363评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,610评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,871评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,582评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,297评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,551评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,053评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,385评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,035评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,079评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,841评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,648评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,550评论 2 270

推荐阅读更多精彩内容