首页 > 免root版 > gg修改器能用的root_GG修改器该怎么用?
gg修改器能用的root_GG修改器该怎么用?
  • gg修改器能用的root_GG修改器该怎么用?

  • 大小:8.56MB日期:2024-4-28 06:26:20
  • 语言:简体中文系统:Android
无病毒 免积分 免充值

工具详情

各位游戏大佬大家好,今天小编为大家分享关于gg修改器能用的root_GG修改器该怎么用?的内容,轻松修改游戏数据,赶快来一起来看看吧。

Python中的OS模块提供了与操作系统交互的功能。

OS属于Python的标准实用程序模块。该模块提供了一种使用操作系统相关功能的可移植方式。

*os*和*os.path*模块包含许多与文件系统交互的函数。

以下是OS模块中的一些功能:

1.os.name:

此函数给出了导入的操作系统依赖模块的名称。

目前已登记下列名称:“POSIX”、“NT”、“os2”、“ce”、“java”和“Riscos”

import os
print(os.name)

产出:

posix

注意:在运行这里的代码时,它可能在不同的解释器上提供不同的输出,例如“POSIX”。

2.os.getcwd():

函数os.getcwd()返回用于执行代码的文件的当前工作目录(CWD)

import os
print(os.getcwd())
# To print absolute path on your system
# os.path.abspath(’.’) 
  
# To print files and directories in the current directory
# on your system
# os.listdir(’.’)

产出:

C:UsersGFGDesktopModuleOS

注意:对于GFG解释器,使用的目录是
oot。

3.OS.错误:

在无效或无法访问的文件名和路径或具有正确类型但操作系统不接受的其他参数时,本模块中的所有函数都会引发OSError。

import os
try:
    # If the file does not exist,
    # then it would throw an IOError
    filename = ’GFG.txt’
    f = open(filename, ’rU’)
    text = f.read()
    f.close()
  
# Control jumps directly to here if 
#any of the above lines throws IOError.    
except IOError:
  
    # print(os.error) will <class ’OSError’>
    print(’Problem reading: ’ + filename)
      
# In any case, the code then continues with 
# the line after the try/except

产出:

Problem reading: GFG.txt

文件对象操作

4.os.popen():

此方法可以打开命令的管道。根据模式是‘r’还是‘w’,可以读取或写入返回值。

语法:

os.mand[, mode[, bufsize]])

参数模式&bufsize不是必需的参数,如果不提供,默认的r为模式。

import os
fd = "GFG.txt"
  
# popen() is similar to open()
file = open(fd, ’w’)
file.write("Hello")
file.close()
file = open(fd, ’r’)
text = file.read()
print(text)
  
# popen() provides a pipe/gateway and accesses the file directly
file = os.popen(fd, ’w’)
file.write("Hello")
# File not closed, shown in next function.

产出:

Hello

注意:没有显示popen()的输出,将直接更改文件。

5.os.lose():

关闭文件描述符FD。使用open()打开的文件只能由CLOSE()关闭。

但是通过os.popen()打开的文件可以用CLOSE()或os.lose()关闭。

如果我们尝试关闭使用open()打开的文件,使用os.lose(),Python将抛出TypeError。

import os
fd = "GFG.txt"
file = open(fd, ’r’)
text = file.read()
print(text)
os.close(file)

产出:

Traceback (most recent call last):
File "C:UsersGFGDesktopGeeksForGeeksOSFile.py", line 6, in
os.close(file)
TypeError: an integer is required (got type _io.TextIOWrapper)

注意:由于不存在文件或权限特权,可能不会引发相同的错误。

6.os.rename():

可以使用函数os.rename()将文件old.txt重命名为new.txt。

只有当文件存在且用户有足够的权限更改该文件时,文件的名称才会更改。

import os
fd = "GFG.txt"
os.rename(fd,’New.txt’)
os.rename(fd,’New.txt’)

产出:

Traceback (most recent call last):
File "C:UsersGFGDesktopModuleOSGeeksForGeeksOSFile.py", line 3, in
os.rename(fd,’New.txt’)
FileNotFoundError: [WinError 2] The system cannot find the
file specified: ’GFG.txt’ -> ’New.txt’

理解产出:

文件名“GFG.txt”存在,因此当第一次使用os.rename()时,文件将被重命名。

第二次调用函数os.rename()时,文件“New.txt”存在,而不是“GFG.txt”

因此,Python抛出FileNotFoundError。

以上就是关于gg修改器能用的root_GG修改器该怎么用?的全部内容,游戏大佬们学会了吗?

技能推荐

热门下载

其他人还在搜