import numpy as np import scipy.io as io creat = locals() tmp = io.loadmat("all.mat") for i in tmp: print i creat[i] = tmp[i] 1D-array转置 np.reshape(xx, (-, ))
可以实现的方法有: globals(),locals(),eval(),exec() 演示: exce法 In [6]: exec('name="bob"') In [7]: name Out[7]: 'bob' globals用法: In [1]: globals()['name']='bob' In [2]: name Out[2]: 'bob'
public class Program { public string str = "spp"; public string spp = "Hello World!"; public static void Main(string[] args) { Program p = new Program(); Console.WriteLine(p.GetType().GetField(p.str).GetValue(p).ToString()); Console.Re
public partial class Form1 : Form { string str = "spp"; public string spp = "very good"; public Form1() { InitializeComponent(); MessageBox.Show(this.GetType().GetField(str).GetValue(this).ToString()); } }
一.重点掌握的6种字符串方法: 1.join命令 功能:用于合并,将字符串中的每一个元素按照指定分隔符进行拼接 程序举例: seq = ['1','2','3','4'] sep = '+' v = sep.join(seq) print(v) test = "学习要思考" t = '***' v = t.join(test) print(v) 2.split命令 功能:与join相反,将字符串拆分为序列 test = '1+2+3+4+5' v = test.split('+') p