文件操作等练习代码

1.练习代码

'''

fileName = input('请输入文件名称:')
contentList = '我是你妈妈'
fileOpen = open(fileName,'a+')
fileOpen.write(contentList)
fileOpen.seek(0)
for line in fileOpen.readlines():
     print(line)

import numpy as np
x = [
    [1,2,3,4],
    [4,3,2,1],
    [5,6,7,8],
    [9,8,7,6]
]
print(type(x))
print(np.array(x).transpose())
print(type(np.array(x).transpose()))
print(np.array(x).T)
y = np.mat(x)
print(y.transpose())
print(type(y))
z = np.matrix(x)
print(z.T)
print(type(z))
x = np.array(range(10))
print(x)
print(x[x>4])'''
import numpy as np
import matplotlib.pyplot as plt

'''
fig = plt.figure()          #首先要定义一个figure对象,可以理解成一张画板
ax1 = fig.add_subplot(221)  #添加轴,可以理解为建立平面直角坐标系
ax1.set(xlim = [0,100],ylim = [-1,1],title = 'an example axes',ylabel = "金钱/t",xlabel = '时间/s')

#plt.show()

ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
ax4.set(xlim = [0,100],ylim = [-1,1],title = 'you mother fucker',ylabel = 'y-axis',xlabel = 'x-ax')

x = np.linspace(0,100,10000)
y = np.cos(x)

ax1.plot(x,y,'-',linewidth = '2',markersize = '12',color = 'green')
ax4.plot(x,y,'--')
plt.show()

plt.plot(x,y,ls = '-',label = 'plot figure',lw = 2)
plt.legend()
plt.show()
fig = plt.figure()
axes = plt.subplots(norows = 2,ncols = 2)
x = np.linspace(0,np.pi)
y_sin = np.sin(x)
y_cos = np.cos(x)
y_constant = x * 0 + 5
axes[0,1].set(title = '11111111',color = 'red')
axes[1,1].set(title = '44444444',color = 'green')

plt.show()'''
import numpy as np
import matplotlib.pyplot as plt

#首先创建对象
fig = plt.figure(figsize=(8,4),facecolor='red')
fig.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值