在python中将字符串作为变量调用(calling string as variable in python)
我在python中创建了一个名为SignalParam的类,包含不同的属性(频率,电压,时间等)
我想创建这种类型的许多实例
vars()['Segment'+str(segment_number)] = SignalParam()
这条线工作,我可以创建变量“Segment1”,“Segment2”,....
我的问题是:我想把那些变种称为
"Segment"+segment_number.freqency=33
I created a class called SignalParam in python containing different properties (frequency, voltage, time, etc)
I would like to create many instances of this type
vars()['Segment'+str(segment_number)] = SignalParam()
this line is working and i can create variables "Segment1", "Segment2", ....
My question is: i would like to call those variabes like
"Segment"+segment_number.freqency=33
原文:https://stackoverflow.com/questions/30851272
满意答案
与事务类似,语句也是原子的。 一旦语句开始执行数据更改,就会保存原始状态(实际上会记录更改)。 如果语句因任何原因失败(超时,与刚刚提交的事务冲突),则必须将更改恢复为原始状态。 该语句将报告失败但事务仍处于打开状态,您可以继续执行该事务,就像从未执行过该语句一样。
这实际上类似于保存点 - 您可以想象在记录每个语句保存点之前和语句完成之后,保存点已提交。 但是,这对外部事务或保存点没有影响。
Similarly to transaction, statement is atomic as well. Once the statement starts performing the data changes, the original state is saved (actually the changes are recorded). If statement fails for whatever reason (timeout, conflict with just committed transaction) the changes must be reverted to the original state. The statement will report a failure but the transaction is still open and you can continue with the transaction just like the statement was never executed.
This is actually similar to savepoint - you can imagine that before each statement savepoint is recorded and after statement is completed, the savepoint is committed. This has no influence on outer transaction or savepoints however.
相关问答
更多MySQL中的语句回滚与事务回滚(Statement rollback vs transaction rollback in MySQL)
@Test之后的回滚事务(Rollback transaction after @Test)
使用带有mysql的Transaction时,我们可以进行多次回滚吗?(Can we have multiple rollback while using Transaction with mysql)
Mysql嵌套事务与回滚(Mysql nested transaction with rollback)
NHibernate MySql事务不会回滚(NHibernate MySql transaction does not rollback)
MySQL ROLLBACK实际上没有回滚(MySQL ROLLBACK not actually rolling back)
mysql事务(提交和回滚)(mysql transaction (commit and rollback))
系统崩溃后mysql事务会回滚吗?(Will mysql transactions rollback after system crash?)
MySQL InnoDB事务回滚不起作用(MySQL InnoDB transaction rollback is not working)
MySQL Workbench:启动事务似乎在回滚之前提交(MySQL Workbench: Start Transaction seems to be committed before rollback)
相关文章
更多Python 字符串操作
Python字符串格式化
Java String类
python2和python3的区别
redis 字符串(String) SET 操作
Python 列表(list)操作
遍历字符串每个字符,Stringreader是不是要比string.toCharArray来的快?
探索 Python,第 1 部分: Python 的内置数值类型
Python学习笔记
Python的文件类型
最新问答
更多sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
湖北京山哪里有修平板计算机的
SimplePie问题(SimplePie Problem)
在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
为什么我会收到链接错误?(Why do I get a linker error?)
如何正确定义析构函数(How to properly define destructor)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!