Python解释器如何查找类型?(How does Python interpreter look for types?)
如果我写的东西如下:
>>> a = float()
Python解释器如何知道在哪里查找类型'float'?
我知道'float'是一个在Lib / types.py中定义的变量,它引用了内置类型
types.FloatType
。 但是,解释器如何为脚本构建所有可能类型的完整列表(包括用户定义和导入模块定义)? 它看起来在哪些地方? 如何在Python脚本中构建这样的列表呢?If I write something like:
>>> a = float()
how does Python interpreter know where to look for type 'float'?
I know that 'float' is a variable defined in Lib/types.py and refers to built-in type
types.FloatType
. But how does the interpreter build a complete list of all possible types for a script (including user-defined and imported-module-defined)? Which places does it look in? And what do I do to build such a list inside a Python script?
原文:
最满意答案
- 更新---将此部分替换为下面提供的代码区域
Dim x2 As Integer = 0 ' Keep a track of index For Each i As Integer In ListBox1.Items ' create a Point with index as x and the actual value of list item as y s.Points.AddXY(Convert.toDouble(x2), Convert.toDouble(i)) x2 = x2+1 Next
图表应该是这样的
Chart1.Series.Clear() 'Empty your chart of any previous values Chart1.Titles.Add("My Line chart") 'Add a Title Dim s As New Series 'Create a new series s.Name = "My Line" 'Series name s.ChartType = SeriesChartType.Line 'Chart type 'Most important part, the points to plot 'Points START s.Points.AddXY(1, 2) s.Points.AddXY(3, 4) s.Points.AddXY(5, 9) 'Points END 'Add the series to the Chart1 control Chart1.Series.Add(s)
我不确定你为什么使用RichTextBox1。 如果你正在收集用户输入(x,y)点,那么你将需要构建你的点。 使用
TextBox
控件而不是RichText
,只要使用给定的描述就足够了。用这个替换上面代码中的Points位
'Assume the user is entering value/numbers separated by "," 'Use the input as both x and y 'e.g 1,2,3,... Dim textCont As String = TextBox.Text Dim boxValues As String() = textCont.Split(New Char() {","}) For Each item In boxValues s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) Next
就您提供的代码而言,本示例中没有使用
ListBox
控件或引用。--Update--- Replace this part in the Points region of code provided below
Dim x2 As Integer = 0 ' Keep a track of index For Each i As Integer In ListBox1.Items ' create a Point with index as x and the actual value of list item as y s.Points.AddXY(Convert.toDouble(x2), Convert.toDouble(i)) x2 = x2+1 Next
A chart should be something like this
Chart1.Series.Clear() 'Empty your chart of any previous values Chart1.Titles.Add("My Line chart") 'Add a Title Dim s As New Series 'Create a new series s.Name = "My Line" 'Series name s.ChartType = SeriesChartType.Line 'Chart type 'Most important part, the points to plot 'Points START s.Points.AddXY(1, 2) s.Points.AddXY(3, 4) s.Points.AddXY(5, 9) 'Points END 'Add the series to the Chart1 control Chart1.Series.Add(s)
I'm not sure why you are using a RichTextBox1. If you are gathering user input (x,y) points then you will need to construct your points. Use a
TextBox
control instead ofRichText
, it should suffice, with the given description.Replace the Points bit in the above code with this
'Assume the user is entering value/numbers separated by "," 'Use the input as both x and y 'e.g 1,2,3,... Dim textCont As String = TextBox.Text Dim boxValues As String() = textCont.Split(New Char() {","}) For Each item In boxValues s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) s.Points.AddXY(Convert.toDouble(item), Convert.toDouble(item)) Next
As far as the code you've provided, there is no
ListBox
control or reference to use in this example.
相关问答
更多-
如何在ios中绘制折线图?(how to draw a line graph in ios? Any control which will help me show graph data in ios)[2022-02-26]
以下是您可能想要查看的一些图形库。 如果它们不符合您的需求,请查看其源代码以了解基本操作是如何完成的。 如果您打算自己动手,则需要了解Core Graphics 。 Ray Wenderlich的网站上有一些教程 还有一些好的图书馆: 核心 在此处 绘制其图表类型的一些样本 JBChartView IOS-图表 Here are some graphing libraries that you may want to look into. If they don't fit your needs, take ... -
您可以将H1和H2系列的可见性设置为false, series: [{ name: 'H1', data: [1, 2, 3], visible: false, showInLegend: false }, { name: 'H2', data: [5, 6, 7], visible: false, showInLegend: false }, { ...
-
从你的问题,我收集到你想要显示所选动物即狗的食物描述(字符串列表) 要在FoodSchedule类中实现此功能,请添加属性 public List
FoodDescriptionList { get { return foodDescriptionList; } } 在您的主表单中,您可以将此集合绑定到列表框 if (animal != null) { //Adds to the list. foodlst.DataS ... -
我认为,如果你设置Listbox的SelectionMode="Single"属性可能会有所帮助。 I use ObservableCollection finally. Although the question I still haven't been solved. XAML :
隔离列表框行中的值(Isolating values from a listbox line)[2023-09-16]
你说这条线是填充的,但不提供任何细节。 如果您知道第一个字段始终是该行的前4个字符,则可以使用string.Substring将其隔离: string field1 = line.Substring(0, 4); 和其他领域类似。 PS请编辑你的帖子并删除发誓的话。 解析添加的代码后编辑 我不明白你的评论,什么是“你的负面价值”? 在调试器中运行代码并找到导致错误的行。 请发布确切的错误消息。 是否有理由将子字符串转换为浮点数然后再转换为字符串? 我可以想象你可能想验证字段是数字,但是你最好使用TryPa ...不可能注入具有不同x轴的数据集。 NVD3是一个图表库,因此在处理数据时没有太多复杂性,因此您需要规范化x轴。 如果您有复杂的数据集,您可以查看Panda,它可以帮助您在具有不同的x轴时对数据集进行规范化, http://pandas.pydata.org/ It's not possible to inject datasets with different x-axis. NVD3 is a chart library and so doesn't put much complexity in proc ...一些说明: Dim tdf1 As TableDef Dim tdf2 As TableDef Dim db As Database Set db = CurrentDb Set tdf1 = db.TableDefs(Me.CompList1.RowSource) For Each fld In tdf1.Fields sFields = sFields & ";" & fld.Name Next sFields = sFields & ";" Set tdf2 = db.TableDef ...你可以试试像 lstbxCharacters.SelectedItem 更新 要从列表框中读取数据,我认为有多种方法(假设它是可读的)。 - >通常列表框显示字符串,所以应该读取字符串变量 Dim a_string as Strin = lstbxCharacters.SelectedItem 您也可以在之前添加一个小支票,确保当前选择了一个项目: If lstbxCharacters.SelectedIndex < 0 then return 如果未选择任何项目,则跳出当前子 最后,要阅读第一个条目 ...如何使用amcharts在单个图形中绘制多个折线图(How I can draw several line graph in one single graph using amcharts)[2022-07-25]
我找到了解决方案。 如果要在单个图形中绘制更多线图。 只需在“图形”中添加额外的id':并在该id中添加额外的valueField。 并在“dataProvider”中添加所需的点: 同样,您可以通过在“graph”中添加ID来为2个以上的图表执行此操作: 并使用.js扩展名保存。 var chart = AmCharts.makeChart("chartdiv", { "type": "serial", "theme": "light", "marginTop":0, "marginRight": 80 ...- 更新---将此部分替换为下面提供的代码区域 Dim x2 As Integer = 0 ' Keep a track of index For Each i As Integer In ListBox1.Items ' create a Point with index as x and the actual value of list item as y s.Points.AddXY(Convert.toDouble(x2), Convert.toDoub ...相关文章
更多- : bad interpreter: 没有那个文件或目录
- Python的文件类型
- 探索 Python,第 1 部分: Python 的内置数值类型
- Mod_python: The Long Story
- Python 基本数据类型
- python2和python3的区别
- python的下载与安装
- Python学习笔记
- Python资源索引 【转载】
- Python基础 缩进和选择
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。