Python使用笔记

目录

1 python中字节与字符串的转换

2 Python3下提示No module named 'tkinter'"问题解决

3 提示没有pip命令

4 问题WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.



python中字节与字符串的转换

#bytes object
byte = b"byte example"

# str object
str = "str example"

# str to bytes 字符串转字节
bytes(str, encoding="utf8")

# bytes to str  字节转字符串
str(byte, encoding="utf-8")

# an alternative method
# str to byte  字符串转为字节
str.encode(str)

# bytes to str  字节转为字符串
bytes.decode(byte)

2 Python3下提示No module named 'tkinter'问题解决

sudo apt search python3-tk

3 提示没有pip命令

https://www.liumingye.cn/archives/250.html

4 问题WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.


python -m pip install torchtext(包名)# python -m 会指定你当前使用的python版本

猜你喜欢

转载自blog.csdn.net/qq_35333978/article/details/117908195