爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 14258|回复: 0

[源代码] [已收纳]python之查看操作系统、本py文件绝对路径、搜索模块路径集

[复制链接]
发表于 2020-12-16 10:02:03 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
本帖最后由 15195775117 于 2021-1-31 00:33 编辑

import sys

#这里tab的对齐方法值得学习
print('''sys.platform返回值对应的平台:
System\t\t\tPlatform
Linux\t\t\tlinux2
Windows\t\t\twin32
Cygwin\t\t\tcygwin
Mac OS X\t\tdarwin
OS/2\t\t\tos2
OS/2 EMX\t\tos2emx
RiscOS\t\t\triscos
AtheOS\t\t\tatheos
''')
print('当前的系统 %s' %sys.platform)
print('本py文件绝对路径:\n',sys.argv)
print('python的搜索模块的路径集:\n',sys.path)#这个在打包时应该有用


输出:

sys.platform返回值对应的平台:

System Platform
Linux linux2
Windows win32
Cygwin cygwin
Mac OS X darwin
OS/2 os2
OS/2 EMX os2emx
RiscOS riscos
AtheOS atheos
                        
当前的系统为 win32
本py文件绝对路径:
['C:/Users/Administrator/Desktop/testSys.py']
python的搜索模块的路径集:
['C:\\Users\\Administrator\\Desktop',......'C:\\ProgramData\\Anaconda3\\python38.zip', ......'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32', ......]
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表