Python编码错误消息

2024-04-23 14:44:45 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我能够让代码工作,通过以下,但也改变了一堆变量名似乎工作。也许我使用的是编码器UTF-8识别的变量。谢谢你的帮助

dt =0.1
a=100
n=int(a/dt)
kgrow=1; kshrink =0.25 
pgrow=kgrow*dt ; 
pshrink=kshrink*dt
length =[] 
l=0
times =[] t=0

for i in range(n):
t+=dt
times.append(t)
randgrow=random.random() 
randshrink=random.random()

length.append(l)

time=np.array(times)
lengths=np.array(length)

plt. plot (times,length)
plt. xlabel('Time')
plt.ylabel('Length') 

Tags: 代码npdtpltrandom编码器arraylength
2条回答

尝试用记事本打开它并将其保存为ANSI编码

Save As.. ANSI Encoding

嗯,也许我在编码方面遇到了最多的问题。。以下是解决问题的“所有”方法

First of all import this one to the your .py file.

导入区域设置

locale.setlocale(locale.LC\u ALL,“”)

After then open the cmd, right click on the title, go preferences.

选择“Lucida Console”作为写入类型

Use "u" before your letters. Like x=input(u"Something: ")

有很多东西我没写,先试试我的朋友

相关问题 更多 >