A1 = {'Yuan':30000,'Alex':100000,'Egon':50000,'Rain': -} #定义字典f= Open ("Test.txt","w+", encoding="UTF-8") #打开文件 forKeyinchA1: #循环遍历字典 A2=(Key,str (A1[key])) #把字典解析成列表 List1=(List (A2)) #转列表 Print (list1) #打印预览列表 list_str=" ". Join (List1) #join (): An array of connection strings. Generates a new string f.write a string, a tuple, an element in a list, and a specified character (delimiter) (List_str+"\ n") #在写入到文件为了格式好看, you can add a \ n line break once per loop. Print (LIST_STR) #打写预览# # # #输入结果
" Connector characters ". Join (list or tuple or string or dictionary)Returns a string that is spliced with a connectorIf the object is a list, tuples are spliced in a subscript elementIf the object is a string, it is a word element that is spliced in unitsIf the object is a dictionary, it is stitched in a single key unitListIn [4]: a = ["123""123"]in ["". Join (a) In [6]: bout['123123'DictionaryIn []: a = {"fdasd":"adsf","afdasdf" :"asdf"}in ["". Join (a) in [+]: bout[ 'fdasdafdasdf'String" AS
//return value is a pointer variable for the local malloc request, which is required after the function call ends
}
/* Method Two, get rid of the string directly a,*/
void Join2 (char *a, char *b) {
//Note that if a A, B in the main function defines a string constant (as follows):
//char *a = "abc";
//char *b = "Def";
//Then the join2 is not feasible.
//must be defined like this:
//char a[4] = "ABC";
//char B[4] = "Def";
While (*a! = ')} {
a++;
}
While
1, directly through the + operation:' Python ' + ', ' +' hello ' + '! ‘Print (s)Printing results:Python, Hello!2. Splicing by Join () method:Convert a list to a stringstrlist=[' Python ', 'hello '! ‘]Print (". Join (strlist)")Printing results:Python, Hello!3, through the format () method splicing:The number of {} in the string is consistent with the number of parameters in the format () method‘{},{}! '. Format (' Python 'hello ')Print (s)Printing results:Python, Hello!4, through the% splicing:'%
about their sickness, disaster, more see violent death in your knife of sentient beings and how many?11, hatred of others is a great loss for themselves.12, each person has life, but not everyone knows life, and even cherish life. Life is a punishment for a man who does not know his life.13. The person who thinks he owns wealth is actually owned by wealth.14, the situation is the cause of distress, put down the love, you can get comfortable.15, the fate is not to muddle through, procrastination
What is the function of the Win7 system book stitch? There are always several fixed applications in our toolbars, such as some friends used to put the browser and some chat tools in the toolbar, so that the use of convenient and quick, summed up is the book needle function, the following share the use of methods, Need friends can come in for reference
Our toolbar there will always be a few fixed applications, such as some friends are accustomed to th
. Add mapper in the Mybatis-fonfig.xml fileNine, test operation1. Create the test catalog in the project/test2. Create a package in the test directoryCn.jbit.mybatis092901.dao3. Create a test class under a packageClass Name: Empdaotest.javaContent:public class Empdaotest {Persistence layer implementations for employee classesprivate static Iempdao Empdao = new Empdaoimpl ();@Testpublic void Testchoose () {EMP emp = new EMP ();Emp.setdeptno (9);Emp.setempname ("Zhang Ping U");Emp.sethiredate (New
{Session.close ();}}Viii. Adding a mapping file reference in a configuration file1. Add mapper in the Mybatis-fonfig.xml fileNine, test operation1. Create the test catalog in the project/test2. Create a package in the test directoryCn.jbit.mybatis092901.dao3. Create a test class under a packageClass Name: Empdaotest.javaContent:public class Empdaotest {Persistence layer implementations for employee classesprivate static Iempdao Empdao = new Empdaoimpl ();/*** Test where*/@Testpublic void Testwh
Usage scenarios:For example, you need to query all student numbers with scores greater than 95, separated by commas into a string, from the Student score table.To prepare the test data:CREATE TABLE score (ID int,score int)INSERT into score values (1,90)INSERT into score values (2,96)INSERT into score values (3,99)It is now necessary to query the result string "2,,3" with a single statement.The SQL Server statements are as follows:Select substring ((SELECT ', ' +cast (id as varchar) from score wh
NVARCHAR (+)) insert into syslanguage values (1, ' hello ', ' hello ', ' Empty ') insert into syslanguage values (2, ' worlds ', ' World ', ' Empty ') insert into syslanguage values (3, ' book ', ' Books ', ' empty ') insert into syslanguage values (4, ' open ', ' on ', ' empty ') I Nsert into Syslanguage values (5, ' save ', ' saving ', ' empty ') INSERT into syslanguage values (6, ' new ', ' new ', ' empty ')So, with system performance in mind, we may use stored procedures to reduce network t
this by programming interfaces rather than implementations.
Dependency Injection . The main use is to inject the constructor function.
To do these two points, we can use test double to replace the dependency and inject it into the tested class for isolation testing.ExampleHere's an example that's hard to test, and it's not perfect to show all the features of the non-testable code, but it also contains at least two features:First of all, its dependencies are new, and these dependencies
function of the printf function in C, if you have a C language basis, look at the document to know. In this way, a string and a set of variables are concatenated with the symbol "%", and the special tags in the string are automatically replaced with the variables in the right variable group:
1
print‘%s%s‘%(‘Python‘,‘Tab‘)
Results:
1
PythonTab
The fifth kind of joinIt's a technique, a function join using a string. This function take
table, provide a table statement
CREATE TABLE [dbo]. [X_roleuser] ([ID] [int] IDENTITY (*) Not NULL,[Roleid] [INT] Not NULL,[UserId] [INT] Not NULL,[COMPANY_ID] [INT] NullCONSTRAINT [Pk_x_roleuser] PRIMARY KEY CLUSTERED([Id] ASC) with (Pad_index = off, Statistics_norecompute = off, Ignore_dup_key = off, Allow_row_locks = on, Allow_page_locks = O N) on [PRIMARY]) on [PRIMARY]
GO
After adding some test data, and then executing the stored procedure EXEC [sp_tabletostring] ' cast ([UserId] as
In MySQL:[SQL] Viewplaincopyprint?--single-row stitching, first find a row, plus a comma, and then the next line of stitching isolatedSelectGroup_concat (E.support) fromENGINES EwhereE.xainch('YES','NO') --The results are as follows: Yes,yes,yes,yes,yes,yes,default,yes --replace the "," in the result of the query with the "* *" numberSelect REPLACE(Group_concat (E.support),',','**') fromENGINES EwhereE.xainch('YES','NO') --The results are as follows: Yes**yes**yes**yes**yes**yes**default*
Tags: MyBatis sql if equalityToday's procedures need to be based on the status of the reception to judge in the database is to take where a>bOr is it aThe detailed code is as follows Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.MyBatis if test is equal how to dynamically stitch SQL
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.