python中如何查看stdin编码?
python中如何查看stdin编码?
1、通过Pythonsys库查看
$python
Python2.7.6(default,Nov132018,12:45:42)
[GCC4.8.4]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importsys
>>>printsys.stdin.encoding
UTF-8
>>>printsys.stdout.encoding
UTF-8
>>>
2、查看环境变量LANG
$echo$LANG
en_US.UTF-8
3、执行locale
$locale
.UTF-8
LANGUAGE=en_US:
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
拓展:
Python使用sys.stdin.readline()实现标准输入。注意默认输入的是字符串(注意这里的strip('\n')表示以\n分隔,否则输出是“字符串+\n”的形式 ),如果是int,float类型则需要强制转换。
如果有多个输入,默认情况下strip()由空格分隔,并返回包含多个字符串的列表。如果要强制转换为int等类型,可以调用map()函数。
以上就是python中查看stdin编码的方法,希望能对大家有所帮助!更多Python学习教程请关注IT培训机构:千锋教育。

猜你喜欢LIKE
相关推荐HOT
更多>>
python里glob模块怎么用?
python里glob模块怎么用?本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。简单介绍:匹配一定的格式文件和文件夹。包含函数:1、glo...详情>>
2023-11-14 23:59:20
python中time.gmtime是什么
python中time.gmtime是什么下面我们就time.gmtime函数的概念、语法、参数、返回值、实例分别进行讲解。1.概念gmtime是把日期和时间转换为格林威...详情>>
2023-11-14 21:58:02
python使用OpenCV画图
python中使用OpenCV画图OpenCV的强大之处的一个体现就是其可以对图片进行任意编辑,处理。下面的这个函数最后一个参数指定的就是画笔的大小1、...详情>>
2023-11-14 19:49:08
python流式读取大文件的两种方法
python流式读取大文件的两种方法1、使用read方法分块读取使用更底层的file.read()方法,与直接循环迭代文件对象不同,每次调用file.read(chunk_...详情>>
2023-11-14 16:48:08热门推荐
python里glob模块怎么用?
沸python中series转dataframe的两种方法
热python实现矩阵乘法运算的几种方法
热pandas遍历dataframe的方法有哪些
新python中time.gmtime是什么
python中RNN和LSTM的基本介绍
Python中for循环进行字典迭代
Python中哈希结构有哪几种?
python使用OpenCV画图
python绝对和相对导入的介绍
python标识符是什么意思?
python中如何查看stdin编码?
python如何访问列表元素?
python如何提取文本信息?
技术干货






