("somefile", "w+"), "Hello World"
Note the opening mode: "w +" instead of "w". Of course, "a" is acceptable.16. ellipsis
In Python3, you can directly use the ellipsis Syntax:
Python 3.2 (r32:88445, Oct 20 2012, 14:09:50)[GCC 4.5.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> ...Ellipsis
In Python2?
>>> class C(object):... def __getitem__(self, item):... return item...>>> C()[1:2, ..., 3](slice(1, 2, None), Ellipsis, 3)>>>
17. unpack the tuples in Python3
I
used to determine whether the string is case-sensitive. If one string is capitalized, False is returned. the previously used format () function and evaluate the string length len () function all belong to the string function library, help (str. replace) can be used to query specific function usage. This function is used to replace the old string with the new string.
# Determine whether the string is in lowercase >>> str1 = "Eastmount" >>> str1.islower () False # string replacement >>>> str2 = '
equal to 5 o'clock, to see the number in front of 5, if the odd is rounded, if the even number will be 5 off, that is, after the end of the revision of the figure is an even number, if there is no "0" in the back of any numbers, then whether the front of the 5 is an odd or even,For example, use the above rules to retain 3 valid digits for the following data: 9.8249=9.82, 9.82671=9.83 9.8350=9.84, 9.8351 =9.84Php:functionRound2 ($num,$precision){ $pow
One: File type judgment:1.is_dir () Determine if the directory is not2.is_file () Determine if the file is not3.is_executeable () to determine if the executable file4.is_readable () judgment is not a readable file5.is_writable () to determine if a file is writable6.is_link () Judging is not a shortcutTwo: File attributes:1.file_exits () file exists2.filesize () file size3.filectime () file creation time4.filemtime () Time of File modification5.fileaction () time last accessed by fileThe status o
' unknown type ';
}
}
FileSize returns the data in bytes, if the large file number or large, you can deal with the number first, the code is as follows
Copy Code code as follows:
Working with file size
function GetSize ($path = ', $size =-1) {
if ($path!== null amp;amp; $size = = 1) {//Only the path is calculated to size, or it can be processed only by numbers
$size = FileSize ($path);
}
if ($size gt;= pow (2, 40)) {
Return
This article describes the use of if statements in go language. Share to everyone for your reference. The specific analysis is as follows:
The IF statement appears to be the same as in C or Java, except that it is not (even forced to use them), and {} is required.
Copy Code code as follows:
Package Main
Import (
"FMT"
"Math"
)
Func sqrt (x float64) string {
If x return sqrt (-X) + "I"
}
Return FMT. Sprint (Math. SQRT (x))
}
Func Main () {
Fmt. Println (sqrt (
),' Right-bottom ' =>array (' lat ' = $lat-$dlat, ' lng ' = + $lng + $dlng));}Virtual Data Results//Call the above functionPublic function Actiongetnearshop () {$scope = 5;//5000 m$lng = Trim (I (' lng/s '));//Longitude$lat = Trim (I (' lat/s '));//Latitude$fourpoint = getaroundcoordinate ($lng, $lat, $scope);//query This range of shops from the database$where = "longitude>". $fourpoint [' Right-bottom ' [' lat ']. "and longitude$storeCoordinate = M (' Store ')->where ($where)->column (' Store_i
; open ("Somefile", "w+"), "Hello World"
Note The open mode: "w+" and not "w", of course "a" is OK16. Ellipsis
In Python3, you can use the ellipsis syntax directly:
Python 3.2 (r32:88445, OCT, 14:09:50) [GCC 4.5.2] on Linux2type ' help ', ' copyright ', ' credits ' or ' License ' for MOR E-information.>>> ... Ellipsis
What about the Python2?
>>> class C (object): ... def __getitem__ (self, item): ... return item...>>> C () [1:2, ..., 3] (Slice (1, 2, None), ellipsis, 3) >>>
Python3 tuples
1 idea: enumerate the z range (2-31), then enumerate the value of x 1-> pow (x, z)> = k/2, find the value of y in the last two parts.2 analysis: 1 The formula can tell that the range of z is 2-31, but the range of x and y is not well determined, so the brute force is definitely TLE.2. These similar questions are usually fixed by two and then searched for the third question in the second part.3. Pay attention to the use of (left + right)/2 for Binary S
is a bug, we should solve it. The above method is to bypass it. Now we can convert double to BigDecimal, and ensure thatIn some casesThe double precision is not lost.
Import java. math. bigDecimal; public class BigDecimalUtil {public static BigDecimal doubleToBigDecimal (double d) {String doubleStr = String. valueOf (d); if (doubleStr. indexOf (". ")! =-1) {int pointLen = doubleStr. replaceAll ("\ d + \\. ",""). length (); // The number of digits after the decimal point. pointLen = pointLen> 16
The following describes the round, floor, ceil, pow, rand, max, min, decbin, bindec, dechex, hexdec, decoct, and Dec functions. Round
Round-rounds the floating point number. The round function syntax is as follows:
Round (float, precision)
The precision parameter indicates the number of precision digits to be preserved after the decimal point. If the parameter precision is not specified, the number is rounded to an integer, for example:
Echo round (
;> List ('abc ')
['A', 'B', 'C']
>>> List ([1, 2, 3])
[1, 2, 3]
30. locals ()
The Return Value of the locals () function indicates the dictionary of the current local symbol table.
31. long (x)
The long () function converts a string or number to a long integer. The conversion of floating point numbers follows the same rules as that of int ().
32. map (function, list ,...)
The map () function applies the function to each item in the list and returns a new list, as shown in the following exa
This question requires the number of modulo k and the number of members and modulo K equals 0.Notice [1,231] The sum of these numbers is not more than 90 or so, and if K is greater than 90 then the result of modulo K is certainly not 0, so K is greater than 90 without solution.Given the size of the data, the number of data groups, the state of the problem is that:DP[I][J][K]: The number of digits for the I-mode K result is J and the number of the sum of the number of modulo k results kThen there
Sample Output2112Topic Analysis:The matrix used to construct Fibonacci is0,1TheSet this matrix to a.Sum=f (b) +f (k+b) +f (2*k+b) +f (3*k+b) +........+f ((n-1) *k+b)Set matrix B as a^k;Then (1) the formula issum=a^b+a^b* (b+b^2+b^3+......+b^ (n-1));Obviously, this time can be done with a binary matrix, in parentheses is the same as the form of POJ 3233.The code is as follows:#include #include#include#include#include#include#defineINF 0x3f3f3f3f#defineLL __int64//int is WA.using namespacestd;str
In the project to use the bank home rounding method, PHP does not have a ready-made method, so wrote a
function Up6down4 ($num, $n) { $pow = POW ($n); $con _a = Floor (Round ($num * $POW * 10,1)); $con _b = Floor (Round ($num * $pow, 1)); $con _c = ($num * $pow
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.