python-2.7

Error: No section: 'default' in Robot Framework using DatabaseLibrary

妖精的绣舞 提交于 2021-02-08 08:32:28
问题 I am using Robot Framework with Database Library to test database queries on localhost. I am running it by XAMPP. This is my test case: *** Settings *** Library DatabaseLibrary *** Variables *** @{DB} robotframework root \ localhost 3306 *** Test Cases *** Select from database [Tags] This Connect To Database MySQLdb @{DB}[0] @{DB}[1] @{DB}[2] @{DB}[3] @{DB}[4] @{results}= Query Select * From tbName Log Many @{results} I have installed MySQLDb for Python 2.7, however, when I run it using pybot

Finding the Index of a character within a string

帅比萌擦擦* 提交于 2021-02-08 08:30:30
问题 This may be worded incorrectly because I'm a wee beginner, but if I have a string how to I find a certain characters index like you can with the .index thing in lists. With a list it makes sense: l = ["cat", "dog", "mouse"] animal = l.index["dog"] will return [1], but how do I do the same thing with strings . . . s = "mouse" animal_letter = s.index["s"] it says there is no attribute .index Is there another way I can do this? 回答1: Try the string.find method. s = "mouse" animal_letter = s.find(

Finding the Index of a character within a string

怎甘沉沦 提交于 2021-02-08 08:30:07
问题 This may be worded incorrectly because I'm a wee beginner, but if I have a string how to I find a certain characters index like you can with the .index thing in lists. With a list it makes sense: l = ["cat", "dog", "mouse"] animal = l.index["dog"] will return [1], but how do I do the same thing with strings . . . s = "mouse" animal_letter = s.index["s"] it says there is no attribute .index Is there another way I can do this? 回答1: Try the string.find method. s = "mouse" animal_letter = s.find(

How I can create a python class that takes it definition from Gtk builder

冷暖自知 提交于 2021-02-08 08:12:20
问题 I have made my whole GUI definition over glade, I'm using PyGObject with python 2.7. I have made some widgets that have ids and I can retrieve those objects by calling the corresponding id, for now I have been doing something like this: class MLPNotebookTab: def __init__(self): builder = Gtk.Builder.new_from_file(UI_FILE) builder.connect_signals(self) self.notebook = builder.get_object('MLPNotebook') def add_tab(self, content): pages = self.notebook.get_n_pages() label = "MLP #" + str(pages +

How I can create a python class that takes it definition from Gtk builder

ぃ、小莉子 提交于 2021-02-08 08:11:44
问题 I have made my whole GUI definition over glade, I'm using PyGObject with python 2.7. I have made some widgets that have ids and I can retrieve those objects by calling the corresponding id, for now I have been doing something like this: class MLPNotebookTab: def __init__(self): builder = Gtk.Builder.new_from_file(UI_FILE) builder.connect_signals(self) self.notebook = builder.get_object('MLPNotebook') def add_tab(self, content): pages = self.notebook.get_n_pages() label = "MLP #" + str(pages +

Recycling operations in Python similar to R vectorization

丶灬走出姿态 提交于 2021-02-08 07:43:21
问题 I'm attempting to learn more about Python functionality by translating R code while noting the different approaches. There's a recycling rule in R concatenation, if the strings are multiples of each other the evaluator will recycle the smaller object to match the length of the larger. Here's an example: lttrs <- c("A", "B", "C") lbl <- "pct" users <- c(1,2) If I wanted to combine these three objects to get "Apct1" "Bpct1" "Cpct1" "Apct2" "Bpct2" "Cpct2" . I can repeat the last object users to

Counting specific characters in a file (Python)

ぃ、小莉子 提交于 2021-02-08 07:39:07
问题 I'd like to count specific things from a file, i.e. how many times "--undefined--" appears. Here is a piece of the file's content: "jo:ns 76.434 pRE 75.417 zi: 75.178 dEnt --undefined-- ba --undefined-- I tried to use something like this. But it won't work: with open("v3.txt", 'r') as infile: data = infile.readlines().decode("UTF-8") count = 0 for i in data: if i.endswith("--undefined--"): count += 1 print count Do I have to implement, say, dictionary of tuples to tackle this or there is an

Change the value of a local variable where variable name will be expressed as a string

冷暖自知 提交于 2021-02-08 07:25:35
问题 I am trying to find a good and secure way to call a variable using string substitution in order to set its value. This is a more best-practices and I am looking for the best possible way to do this. First of all, using dictionary or similar structure is not what I want. I wish to set the value of a variable! Example; def test_my_var(name_param, val): # Set initial values for each variable my_var_1 = -1 my_var_2 = -1 my_var_3 = -1 ... my_var_n = -1 # Now I will update the value of mth variable

Change the value of a local variable where variable name will be expressed as a string

早过忘川 提交于 2021-02-08 07:25:26
问题 I am trying to find a good and secure way to call a variable using string substitution in order to set its value. This is a more best-practices and I am looking for the best possible way to do this. First of all, using dictionary or similar structure is not what I want. I wish to set the value of a variable! Example; def test_my_var(name_param, val): # Set initial values for each variable my_var_1 = -1 my_var_2 = -1 my_var_3 = -1 ... my_var_n = -1 # Now I will update the value of mth variable

Creating Executable File For Python 2.7

故事扮演 提交于 2021-02-08 06:54:19
问题 I want to make an executable file from a python file the python file is written for Python 2.7. I tried pyinstaller but it gives me an error when installing. I'm guessing it does not have support for Python 2.7 anymore. Are there any alternatives for pyinstaller that work with Python 2.7? I tried installing cx_Freeze version 5.1.1 but it gives me the following error: Cleaning up... Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\win-10\\appdata\\local\\temp